<?php
	global $validation;
  $validation = true;
	$validate=get_input('validate');

if(isset($_SESSION['user'])){
	if((!isset($validate) || empty($validate)) && $_SESSION['user']->getGUID()==$vars['entity']->getOwner() && $vars['entity']->validate=='valide'){
		?>
		<?php if($comments_on==true){ ?>
		<div id="validation" class="flora ui-tabs-nav">
			<ul id="pel_menu">
				<li>
					<a href="#fragment-1">
						<span><?php echo elgg_echo('categorie:validation'); ?></span>
					</a>
				</li>
				<li><a href="#fragment-2"><span><?php echo elgg_echo('comments'); ?></span></a></li>
			</ul>
		  <div id="fragment-1">
		    <?php
		    echo elgg_view('rate/viewrate', array('entity'=> $vars['entity']));
		    ?>
		  </div>
			<div id="fragment-2">
			 	<?php
					$comments = list_annotations($vars['entity']->getGUID(),'generic_comment');
					$comments .= elgg_view('comments/forms/edit',array('entity' => $vars['entity']));
					echo $comments;
				?>
			 </div> 
		</div>
		<?php }
		else{?>
			<div id="validation" class="flora ui-tabs-nav">
			<ul id="pel_menu">
				<li>
					<a href="#fragment-1">
						<span><?php echo elgg_echo('categorie:validation'); ?></span>
					</a>
				</li>
			</ul><br/>
		  <div id="fragment-1">
		    <?php
		    echo elgg_view('rate/viewrate', array('entity'=> $vars['entity']));
		    ?>
		  </div>
		</div>
			<?php }?>
	<?php	
	}
	else if((!isset($validate) || empty($validate)) && $vars['entity']->access_id==2 && $vars['entity']->validate=='valide')
	{
		if($comments_on==true){
		?>
				<div id="validation" class="flora ui-tabs-nav">
			<ul id="pel_menu">
				<li>
					<a href="#fragment-1">
						<span><?php echo elgg_echo('categorie:validation'); ?></span>
					</a>
				</li>
				<?php if($comments_on==true){ ?>
				<li><a href="#fragment-2"><span><?php echo elgg_echo('comments'); ?></span></a></li>
				<?php } ?>
			</ul>
		  <div id="fragment-1">
		    <?php
		    echo elgg_view('rate/viewrate', array('entity'=> $vars['entity']));
		    ?>
		  </div>
			<div id="fragment-2">
			 	<?php
					$comments = list_annotations($vars['entity']->getGUID(),'generic_comment');
					$comments .= elgg_view('comments/forms/edit',array('entity' => $vars['entity']));
					echo $comments;
				?>
			 </div> 
		</div>
		<?php }
		else{ ?>
			<div id="validation" class="flora ui-tabs-nav">
			<ul id="pel_menu">
				<li>
					<a href="#fragment-1">
						<span><?php echo elgg_echo('categorie:validation'); ?></span>
					</a>
				</li>
			</ul><br/>
		  <div id="fragment-1">
		    <?php
		    echo elgg_view('rate/viewrate', array('entity'=> $vars['entity']));
		    ?>
		  </div>
		</div>
		<?php }
	}
	else if((!isset($validate) || empty($validate)) && $vars['entity']->validate!='valide'){
		if($comments_on==true){
		?>
		<div id="validation" class="flora ui-tabs-nav">
			<ul id="pel_menu">
				<li><a href="#fragment-2"><span><?php echo elgg_echo('comments'); ?></span></a></li>
			</ul>
			<div id="fragment-2">
			 	<?php
					$comments = list_annotations($vars['entity']->getGUID(),'generic_comment');
					$comments .= elgg_view('comments/forms/edit',array('entity' => $vars['entity']));
					echo $comments;
				?>
			 </div> 
		</div>
		<?php
		}
		else{ ?>
		<div>
		</div>
	<?php
		}
	}
	
	
	else if($validate==true && $_SESSION['user']->role!='student'){

?>
<div id="validation" class="flora ui-tabs-nav"> 
			<ul id="pel_menu">
				<li>
					<a href="#fragment-1">
						<span><?php echo elgg_echo('categorie:validation'); ?></span>
					</a></li>
				<?php if($comments_on==true){ ?>
					<li><a href="#fragment-2"><span><?php echo elgg_echo('comments'); ?></span></a></li>
				<?php }
				else{ ?>
					&nbsp;
					<?php }?>
			</ul>
		  <div id="fragment-1">
		    <?php
		    echo elgg_view('rate/rate', array('entity'=> $vars['entity']));
		    ?>
		  </div>
			<?php if($comments_on==true){ ?>
		  <div id="fragment-2">
			 	<?php
					$comments = list_annotations($vars['entity']->getGUID(),'generic_comment');
					$comments .= elgg_view('comments/forms/edit',array('entity' => $vars['entity']));
					echo $comments;
				?>
			 </div>
			<?php } ?>
		</div>
<?php
	}
}
?>